/**
 * @Author: 安广伟
 * @Email: anguangwei@jwzh.tech
 * @Date: 2024-09-09 15:02:42
 * @LastEditTime 2024-09-09 15:02:42
 * @since: 1.0.0
 * @Version: 1.0.0
 * @Description:
 */

package com.ry.mall.server.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Slf4j
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(@NonNull CorsRegistry registry) {
        log.debug("跨域配置起效。");
        registry.addMapping("/**")
                .allowedOriginPatterns("*") // Vite 前端地址
                .allowedMethods("*")
                .allowCredentials(true)
                .allowedHeaders("*");
    }
}
